<?php
$cat=$_GET["cat"];
$catValue1=$_GET["catValue1"];
$catValue2=$_GET["catValue2"];

$con = mysql_connect('127.0.0.1', 'root', '');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("webshop", $con);

if($cat == 1){
	$sql="SELECT cat1 FROM producten where cat1 <> '' group by cat1 order by cat1";
}

if($cat == 2){
	$sql="SELECT cat2 FROM producten where cat1 = '$catValue1' and cat2 <> '' group by cat2 order by cat2";
}

if($cat == 3){
	$sql="SELECT cat3 FROM producten where cat1 = '$catValue1' and cat2 = '$catValue2' and cat3 <> '' group by cat3 order by cat3";
}
//echo $sql;
if (!$sql)
{
    error_log("Query $myquery failed: " . mysql_error());
    echo mysql_error();
}
$result = mysql_query($sql) or die(mysql_error());	
echo "$cat\n";
if($cat == 1){
	while($row = mysql_fetch_array($result)){
		echo $row['cat1'];
		echo "\n";
	}
}

if($cat == 2){
	while($row = mysql_fetch_array($result)){
		echo $row['cat2'];
		echo "\n";
	}
}
if($cat == 3){
	while($row = mysql_fetch_array($result)){
		echo $row['cat3'];
		echo "\n";
	}
}

?> 